package cn.jeefast.rest.service.impl;

import cn.jeefast.common.entity.MbMessage;
import cn.jeefast.common.utils.R;
import cn.jeefast.rest.dao.MbMessageDao;
import cn.jeefast.rest.service.MbMessageService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author theodo
 * @since 2020-01-02
 */
@Service
public class MbMessageServiceImpl extends ServiceImpl<MbMessageDao, MbMessage> implements MbMessageService {
    @Autowired
    private MbMessageDao mbMessageDao;

    @Override
    public R list(Long docId, Integer page, Integer limit) {
        page = (page-1)*limit;
        List<MbMessage> mbMessages = mbMessageDao.mesgList(docId, page, limit);
        EntityWrapper ew = new EntityWrapper();
        ew.eq("to_doc",docId);
        List list = mbMessageDao.selectList(ew);
        Map map = new HashMap();
        map.put("dataList",mbMessages);
        map.put("count",list.size());
        return R.ok("").put("data",map);
    }
}
